#!/bin/bash


cd "`pwd`"

INPUT=$1

usage(){
    [ "$1" = "1" ] && echo "File $INPUT not found"
    echo "Usage : $0 input_file"
    exit 1
}

[ "$INPUT" = "" ] && usage 0
[ -f "$INPUT" ] || usage 1



timestamp=`stat -t %Y%m%d%H%M%S  "$INPUT" | awk '{print $10}' | sed -e "s/\"//g"`
bname=`basename "$INPUT"`
dname=`dirname "$INPUT"`

if echo "$bname" | grep -qv "^$timestamp"
then
    echo "mv $INPUT ${dname}/${timestamp}-${bname}"
    mv "$INPUT" "${dname}/${timestamp}-${bname}"
else 
    echo "Ignoring $INPUT"
fi